<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>title</title>
  </head>
  <body>
    <script src="https://unpkg.com/vue@next"></script>
    <div id="root"></div>

    <script>
      // v-once 让某个元素只渲染一次
      //ref 实际上是获取DOM节点 / 组件引用的一个语法

      //provide inject
      const app = Vue.createApp({
        data() {
          return {
            count: 1,
          };
        },

        provide() {
          return {
            count: this.count,
          };
        },

        //template: `
        //          <div @click="count += 1" v-once>{{count}}</div>
        //        `,

        //mounted() {
        //  console.log(this.$refs.count);
        //  this.$refs.count.innerHTML = "hello";
        //},

        //mounted() {

        // console.log(this.$refs.yunmu);

        // this.$refs.yunmu.sayHello();
        //},

        template: `
                  <div>
                        <child/>
                        <button @click="count += 1">按钮</button>
                   </div>
                `,
      });

      app.component("child", {
        template: `<child-child/>`,
      });

      app.component("child-child", {
        inject: ["count"],
        template: `<div>{{count}}</div>`,
      });

      //  app.component("hello",{
      //    methods:{
      //        sayHello(){
      //            console.log("sayHello");
      //        }
      //    },
      //    template:`hello`
      //  })

      const vm = app.mount("#root");
    </script>
  </body>
</html>
